<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        body {
            min-height: 100vh;
            background-color: #abefe9;
        }

        body>div {
            margin: 5px;
            border: #bfa 3px solid;
        }

        hr {
            background-color: red;
            height: 1px;
            border: 0;
        }

        .d1 {
            background-color: #FFCCCC;
            width: 100px;
            height: 100px;
            position: absolute;
            top: 10px;
            left: 10px;
        }

        .d2 {
            background-color: #cfc;
            width: 100px;
            height: 100px;
            position: absolute;
            left: 30px;
            top: 30px;
        }

        .d3 {
            background-color: #ccf;
            width: 100px;
            height: 100px;
            position: absolute;
            top: 50px;
            left: 50px;
        }

        .d4 {
            background-color: #FFCCCC;
            width: 100px;
            height: 100px;
            position: absolute;
            top: 10px;
            right: 10px;
            z-index: 3;
        }

        .d5 {
            background-color: #cfc;
            width: 100px;
            height: 100px;
            position: absolute;
            top: 30px;
            right: 30px;
            z-index: 2;
        }

        .d6 {
            background-color: #ccf;
            width: 100px;
            height: 100px;
            position: absolute;
            top: 50px;
            right: 50px;
            z-index: 1;
        }

        .d7 {
            background-color: #ccf;
            width: 300px;
            height: 300px;
            position: absolute;
            top: 10px;
            left: 0;
            right: 0;
            margin: 0 auto;;
            z-index: 10;
        }
        .d71 {
            background-color: #cfc;
            width: 200px;
            height: 200px;
            position: absolute;
            top: 10px;
            left: 0;
            right: 0;
            margin: 0 auto;;
            z-index: 1;
        }
    </style>
</head>

<body>
    <div class="d1">1</div>
    <div class="d2">2</div>
    <div class="d3">3</div>

    <div class="d4">4</div>
    <div class="d5">5</div>
    <div class="d6">6</div>


    <div class="d7">
        <div class="d71">
            通过z-index设置元素层级，数字越大层级越高
            <hr>
            层级相同时，后面的元素高于前面的元素
            <hr>
            子元素永远高于父元素
        </div>
    </div>
    <!-- 
        通过
     -->
</body>

</html>